* ===========================================================================*
*                 Bureaucratic politics and aid allocation:                  *
*         Evidence from the U.S. Agency for International Development        *
*              Authors: Gus Greenstein, Mirko Heinzel                        *
*                             Version: 28.11.2025                            *
*                                 Stata 18.0                                 *
* ===========================================================================*


*install packages if necessary
*ssc install reghdfe
*ssc install ppmlhdfe
*ssc install blindschemes
*ssc install ivreghdfe
*ssc install sum2docx
*ssc install psacalc
*ssc install plausexog
*ssc install estout

cd "location of downloaded files"


cd "/Users/mirkoheinzel/Documents/Publications/OPM/1_replication/"
 

*Table 1
use "Greenstein_Heinzel_2025_RG.dta", clear

xtset ctry_id year
	
ivreghdfe log_amount l2.staff_share  ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m1

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l2.staff_share ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m2

ivreghdfe log_amount ( l.log_staff =l5.log_staff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m3

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa ( l.log_staff =l5.log_staff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m4

ivreghdfe log_amount ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m5

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m6

ivreghdfe log_amount ( l.log_staff =l5.log_staff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m7

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa ( l.log_staff =l5.log_staff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m8

estfe . m1 m2 m3 m4 m5 m6 m7 m8 , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4 m5 m6 m7 m8 using Table_1.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


**************
* Appendix B *
**************

*Table B1
ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l.poli_glob_kof l.eco_glob_kof l.pl_fh l.cl_fh  l.politterr_s_pts l.natomem_mem l.taxhav_th l.natresource_rents_wdi l.chrpc_rcs l.communist_binary_brrd l2.staff_share ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m1

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l.poli_glob_kof l.eco_glob_kof l.pl_fh l.cl_fh  l.politterr_s_pts l.natomem_mem l.taxhav_th l.natresource_rents_wdi l.chrpc_rcs l.communist_binary_brrd ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m2

estfe . m1 m2   , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2  using Table_B1.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B2

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l.log_amount_dod l.log_amount_state l2.staff_share ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m1

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l.log_amount_dod l.log_amount_state ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m2

estfe . m1 m2   , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2  using Table_B2.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B3

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l2.staff_share ( l2.log_staff =l3.instrument_aidstaff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m1

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l2.staff_share ( l3.log_staff =l4.instrument_aidstaff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m2

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa ( l2.log_staff =l3.instrument_aidstaff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m3

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa ( l3.log_staff =l4.instrument_aidstaff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m4

estfe . m1 m2 m3 m4  , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4 using Table_B3.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B4

reghdfe log_amount l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m1

reghdfe log_amount l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) 
eststo m2

ppmlhdfe constant_amount_usaid l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m3

ppmlhdfe constant_amount_usaid l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) 
eststo m4

estfe . m1 m2 m3 m4  , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4 using Table_B4.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B5

reghdfe log_amount l.log_professional   l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m1

reghdfe log_amount l.log_technical l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m2

reghdfe log_amount l.log_total l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m3

reghdfe log_amount l.log_professional   l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) 
eststo m4

reghdfe log_amount l.log_technical l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) 
eststo m5

reghdfe log_amount l.log_total l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) 
eststo m6

estfe . m1 m2 m3 m4 m5 m6 , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4 m5 m6 using Table_B5.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')



*Table B6

cmp setup

eststo m1: cmp (any_aid = l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi l.theta_mean_fa i.year) (log_amount_cmp =  l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi l.theta_mean_fa i.year ) if sum_aid>0, indicators($cmp_probit $cmp_cont ) iterate(50) difficult cl(ctry_id)

eststo m2: cmp (any_aid = l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi l.theta_mean_fa i.ctry_id i.year) (log_amount_cmp =  l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi l.theta_mean_fa i.ctry_id i.year ) if sum_aid>0, indicators($cmp_probit $cmp_cont ) iterate(50) difficult cl(ctry_id)

estfe . m1 m2   , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2  using Table_B6.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B7

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l2.staff_share ( l.log_staff =l2.instrument_aidstaff) , absorb( year) cluster(ctry_id) first savefirst
eststo m1

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  ( l.log_staff =l2.instrument_aidstaff) , absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m2

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l2.staff_share ( l.log_staff =l2.instrument_aidstaff) if max_log_staff>0, absorb( year) cluster(ctry_id) first savefirst
eststo m3

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  ( l.log_staff =l2.instrument_aidstaff) if max_log_staff>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m4

estfe . m1 m2 m3 m4  , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4 using Table_B7.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B8

reghdfe log_amount l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0 & year<1989, absorb( year) cluster(ctry_id) 
eststo m1

reghdfe log_amount l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0 & year>1988 & year<1993, absorb( year) cluster(ctry_id) 
eststo m2

reghdfe log_amount l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0 & year>1992 & year<2000, absorb( year) cluster(ctry_id) 
eststo m3

reghdfe log_amount l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0 & year>2000 & year<2009, absorb( year) cluster(ctry_id) 
eststo m4

reghdfe log_amount l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0 & year>2008 & year<2017, absorb( year) cluster(ctry_id) 
eststo m5

reghdfe log_amount l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0 & year>2016 & year<2022, absorb( year) cluster(ctry_id) 
eststo m6

estfe . m1 m2 m3 m4 m5 m6 , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4 m5 m6 using Table_B8.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B9

ivreghdfe log_amount_state l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l2.staff_share ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m1

ivreghdfe log_amount_state l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa ( l.log_staff =l2.instrument_aidstaff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m2

estfe . m1 m2   , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2  using Table_B9.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B10

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l2.staff_share ( l.aid_staff =l2.instrument_aidstaff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m1

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa ( l.aid_staff =l5.aid_staff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m2

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa ( l.aid_staff =l2.instrument_aidstaff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m3

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa ( l.aid_staff =l5.aid_staff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m4

estfe . m1 m2 m3 m4 , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4 using Table_B10.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B11
reghdfe log_amount d_log_staff   l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m1

reghdfe log_amount c.d_log_staff##i.staff_decline l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m2

estfe . m1 m2  , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 using Table_B11.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Table B12

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l2.staff_share l.log_expcountry ( l.aid_staff =l2.instrument_aidstaff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m1

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l.log_expcountry  ( l.aid_staff =l5.aid_staff) if sum_aid>0, absorb( year) cluster(ctry_id) first savefirst
eststo m2

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l.log_expcountry ( l.aid_staff =l2.instrument_aidstaff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m3

ivreghdfe log_amount l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa l.log_expcountry ( l.aid_staff =l5.aid_staff) if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) first savefirst
eststo m4

estfe . m1 m2 m3 m4  , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4  using Table_B12.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')



**************
* Appendix C *
**************

*Table C1
sum2docx log_amount log_staff life_exp_wdi gdppc_wdi_pw lnpop_wdi_pw  v2x_pubcorr_vdem v2x_civlib_vdem v2x_polyarchy_vdem ideal_diff log_fdi theta_mean_fa instrument_aidstaff staff_share disbursement_clean log_meanexp using Table_C1.docx if sample_descriptives==1, stats(N mean sd min max)


*Table C2

reghdfe log_staff l.instrument_aidstaff l.staff_share l.aid_staff_us if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m1

reghdfe log_staff l.instrument_aidstaff l.staff_share l.aid_staff_us l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m2

reghdfe log_staff l.instrument_aidstaff l.staff_share l.aid_staff_us if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) 
eststo m3

reghdfe log_staff l.instrument_aidstaff l.staff_share l.aid_staff_us l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) 
eststo m4

estfe . m1 m2 m3 m4  , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4 using Table_C2.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Figure C1

use "rotation_compliance.dta", clear
graph hbar percentage_rotates if uninterrupted_yearsUS<11, over(uninterrupted_yearsUS) scheme(plotplainblind) ytitle("Percentage rotated out")


*Table C3
use "ttest_data.dta", clear

tempname  memhold1  memhold2
tempfile  ttest_rotUS_vs_stayUS   ttest_rotUS_vs_stayField
postfile `memhold1' str20 varname ///
        rotUS_mean stayUS_mean diff pval using `ttest_rotUS_vs_stayUS', replace		
postfile `memhold2' str20 varname ///
        rotUS_mean stayField_mean diff pval using `ttest_rotUS_vs_stayField', replace
local vars pay_num age_median los_median professional technical authority


use "ttest_data.dta", clear
gen byte group1 = .
replace group1 = 1 if rotated_out_of_US == 1
replace group1 = 0 if stayed_in_US       == 1
drop if missing(group1)

foreach v of local vars {
    quietly ttest `v', by(group1)
    if !missing(r(mu_1)) & !missing(r(mu_2)) {
        post `memhold1' ("`v'") (r(mu_1)) (r(mu_2)) (r(mu_1)-r(mu_2)) (r(p))
    }
}
postclose `memhold1'


use "ttest_data.dta", clear
gen byte group2 = .
replace group2 = 1 if rotated_out_of_US == 1
replace group2 = 0 if stayed_in_field   == 1
drop if missing(group2)

foreach v of local vars {
    quietly ttest `v', by(group2)
    if !missing(r(mu_1)) & !missing(r(mu_2)) {
        post `memhold2' ("`v'") (r(mu_1)) (r(mu_2)) (r(mu_1)-r(mu_2)) (r(p))
    }
}
postclose `memhold2'


use `ttest_rotUS_vs_stayUS', clear
display _newline(1) "=== Rotated-out-of-US  vs  Stayed-in-US ==="
list, sep(0)

use `ttest_rotUS_vs_stayField', clear
display _newline(1) "=== Rotated-out-of-US  vs  Stayed-in-Field ==="
list, sep(0)


**************
* Appendix F *
**************

*Table F1
use "Greenstein_Heinzel_2025_RG.dta", clear

reghdfe log_amount c.l.log_staff##c.disbursement_clean  l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m1

reghdfe log_amount c.l.log_meanexp##c.l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
eststo m2

reghdfe log_amount c.l.log_staff##c.disbursement_clean  l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) 
eststo m3

reghdfe log_amount c.l.log_meanexp##c.l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb(ctry_id year) cluster(ctry_id) 
eststo m4

estfe . m1 m2 m3 m4   , labels(ctry_id "Country fixed effects" year "Year fixed effects")

esttab m1 m2 m3 m4  using Table_F1.rtf, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) b(4) r2 pr2 se mlabels(,titles) l indicate(`r(indicate_fe)')


*Figure F1
reghdfe log_amount c.disbursement_clean##c.l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
quietly margins ,  at(disbursement_clean=(0(0.2)1) l.log_staff=(0(1)3))  vsquish 
marginsplot, scheme(plotplainblind) ylabel(5(5)25)


*Figure F2
reghdfe log_amount c.l.log_meanexp##c.l.log_staff l.life_exp_wdi l.gdppc_wdi_pw l.lnpop_wdi_pw l.v2x_pubcorr_vdem l.v2x_civlib_vdem  l.v2x_polyarchy_vdem  l.ideal_diff l.log_fdi  l.theta_mean_fa  if sum_aid>0, absorb( year) cluster(ctry_id) 
quietly margins ,  at(l.log_meanexp=(0(0.5)4) l.log_staff=(0(1)3))  vsquish 
marginsplot, scheme(plotplainblind) ylabel(5(5)25)





